'use strict';
'use strict';

/* Services */

// Demonstrate how to register services
// In this case it is a simple value service.
angular.module('aotaApp.services', ['ngResource'])
    .factory('stcStatService', function ($resource) {
        return $resource(HOST + 'statistics/static', {}, {
            query: {
                method: 'GET',
                isArray: false
            }
        });
    })
    .factory('updateSqcService', function ($resource) {
        return $resource(HOST + 'app/res/sequence/:appId/:sequence', {}, {
            save: {
                method: 'POST',
                params: {
                    appId: '@appId',
                    sequence: '@sequence'
                },
                isArray: false
            }
        });
    })
    .factory('appService', function ($resource) {
        return $resource(HOST + 'app/res/add', {}, {
            save: {
                method: 'POST',
                data: {
                    appName: '@appName',
                    apkPackName: '@apkPackName',
                    appSize: '@appSize',
                    appStartGrade: '@appStartGrade',
                    appDeveloper: '@appDeveloper',
                    appDetail: '@appDetail',
                    appPermission: '@appPermission',
                    appIconUUID: '@appIconUUID',
                    appImgUUIDs: '@appImgUUIDs',
                    sourceChannel: '@sourceChannel',
                    versionName: '@versionName',
                    versionCode: '@versionCode',
                    appUrlUUID: '@appUrlUUID',
                    appOsVersion: '@appOsVersion',
                    appCuReference: '@appCuReference'
                },
                isArray: false
            },
            remove: {
                url: HOST + 'app/res/del',
                method: 'POST',
                data: '@ids'
            },
            pkg: {
                url: HOST + 'app/res/putpackage',
                method: 'POST',
                data: '@ids'
            },
            isArray: false
        });
    })
    .factory('modifyService', function ($resource) {
        return $resource(HOST + 'app/res/detail/:appId', {}, {
            query: {
                method: 'GET',
                params: {
                    appId: '@appId'
                },
                isArray: false
            },
            save: {
                url: HOST + 'app/res/update',
                method: 'POST',
                isArray: false
            }
        });
    })
    .factory('publishService', function ($resource) {
        return $resource(HOST + 'curef/list', {}, {
            query: {
                method: 'GET',
                params: {},
                isArray: false
            },
            queryPublished: {
                method: 'GET',
                url: HOST + 'app/curefs/:appId',
                params: {
                    appId: "@appId"
                },
                isArray: false
            }
        });
    })
    .factory('ruleService', function ($resource) {
        return $resource(HOST + 'strategy', {}, {
            query: {
                method: 'GET',
                params: {
                    upgradePeriod: '@upgradePeriod',
                    autoDownwifi: '@autoDownwifi',
                    delUpgradeapk: '@delUpgradeapk',
                    clearCache: '@clearCache'
                },
                isArray: false
            },
            save: {
                url: HOST + 'strategy/update',
                method: 'POST',
                params: {
                    id: 1,
                    upgradePeriod: '@upgradePeriod',
                    autoDownwifi: '@autoDownwifi',
                    delUpgradeapk: '@delUpgradeapk',
                    clearCache: '@clearCache'
                },
                isArray: false
            }
        });
    });